home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1033 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. Path: newsfeed.internetmci.com!xmission!news
  2. From: tknarr@xmission.com  ( Todd Knarr )
  3. Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3
  4. Subject: Re: Hungarian notation
  5. Date: 9 Jan 1996 01:57:49 GMT
  6. Organization: Chaos Central
  7. Message-ID: <4csi2t$gsa@news.xmission.com>
  8. References: <30C40F77.53B5@swsbbs.com> <30EF0415.6FE1@tus.ssi1.com> <1996Jan7.045815.8676@ohstpy> <4cpb00$nqk@news.xmission.com> <4crm6i$24mi@navajo.gate.net>
  9. Reply-To: tknarr@xmission.com ( Todd Knarr )
  10. NNTP-Posting-Host: slc31.xmission.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4crm6i$24mi@navajo.gate.net>, feathers@gate.net (Michael Feathers) writes:
  14. >I've never seen a variable that can be any of 9 different types in C++.
  15. >All variables have a type.  Period.  A type can be a union or a base 
  16. >class, but all variables have one and only one type in C++.  If you don't
  17. >believe me, check the ARM.
  18.  
  19. You haven't worked with polymorphic classes as reference arguments or
  20. pointers much, then. I have the following class heirarchy:
  21.  
  22. Stall
  23.         AvailableStall
  24.         AssignedStall
  25.         OccupiedStall
  26.         DirtyStall
  27.         BeingCleanedStall
  28.         BrokenStall
  29.         OutOfServiceStall
  30.         AlarmStall
  31.         OfflineStall
  32.  
  33. That's 9 subclasses of Stall. I do, though, routinely have arguments that
  34. are pointers or references to Stall. The actual object may be any one of
  35. those 9 subclasses.
  36.  
  37. Give me an HN prefix that tells me that, in the following prototype
  38.  
  39. Stall *HardwareChangeSignalled( Stall& ExistingStall, int ByteCount,
  40.                                 unsigned char *aHardwareData );
  41.  
  42. the ExistingStall argument is one of the 9 subclasses and never a Stall,
  43. and the returned pointer is one of the 9 subclasses and never a pointer to
  44. Stall.
  45.  
  46. Without such a prefix, you can readily get the obnoxious situation of a new
  47. programmer depending on the prefix and not realizing that he is dealing with
  48. a polymorphic type. This can cause him problems if he refers to the source
  49. code for Stall, depending on the HN prefix to be the actual type.
  50.  
  51. --
  52. Todd Knarr : tknarr@xmission.com      |  finger for PGP public key
  53.                                       |  Member, USENET Cabal
  54.  
  55. Seriously, I don't want to die just yet.  I don't care how
  56. good-looking they are, I! don't! want! to! die!"
  57.                                         -- Megazone ( UF1 )
  58.  
  59.